import {Component, OnInit} from '@angular/core';
import {ListConActivityForecastComponent} from '../list-con-activity-forecast.component';
import {Zero3Option} from '../../../../../frame/enum/zero3-option';
import {ConActivityForecastCondition} from '../../con-activity-forecast.type';
import * as fa from '@fortawesome/free-solid-svg-icons';

@Component({
    selector: 'app-search-list-con-activity-forecast',
    templateUrl: './search-list-con-activity-forecast.component.html',
    styleUrls: ['./search-list-con-activity-forecast.component.css']
})
export class SearchListConActivityForecastComponent implements OnInit {

    // func = this.upper.func;

    zero3Option = Zero3Option;

    condition = new ConActivityForecastCondition();

    extend = {
        keyup: (event) => {
            // T-O-D-O 51 # err
            if (event.keyCode > 32 || event.keyCode === 8) {
                this.listConActivityForecast.func.list.click(event);
            }
        },
        condition: {
            upper: {
                type: '',
                icon: fa.faSearchPlus,
                nickname: '上级对象',
                value: () => {
                    return this.condition.upper;
                },
                keyup: (event) => {
                    this.condition.upper = event.target.value;
                    this.extend.keyup(event);
                }
            },
            serNum: {
                icon: fa.faPen,
                nickname: '编号',
                value: () => {
                    return this.condition.serNum;
                },
                keyup: (event) => {
                    this.condition.serNum = event.target.value;
                    this.extend.keyup(event);
                }
            },
            serAudit: {
                icon: fa.faList,
                nickname: '审核状态',
                // value: '',
                change: (event) => {
                    // this.condition.serAuditList = [];
                    // console.log(this.field.serAudit.value);
                    // this.condition.serAuditList = this.field.serAudit.value.split(',');
                    console.log(this.condition.serAuditList);
                }
            },
            creator: {
                icon: fa.faUserAlt,
                nickname: '创建者',
                value: () => {
                    return this.condition.creator;
                },
                keyup: (event) => {
                    this.condition.creator = event.target.value;
                    this.extend.keyup(event);
                }
            },
            createTime: {
                icon: fa.faCalendar,
                nickname: '创建时间',
                value: () => {
                    // return `${this.condition.createTimeOUTSET} - ${this.condition.createTimeFINISH}`;
                    return this.condition.createTime;
                },
                focus: (event) => {
                    const dataOF = event.target.value.toString().split(' ~ ');
                    this.condition.createTimeOUTSET = dataOF[0];
                    this.condition.createTimeFINISH = dataOF[1];
                    this.listConActivityForecast.func.list.click(event);
                },
                blur: (event) => {
                    this.extend.condition.createTime.focus(event);
                }
            },
            serMemo: {
                icon: fa.faPen,
                nickname: '备注',
                value: () => {
                    return this.condition.serMemo;
                },
                keyup: (event) => {
                    this.condition.serMemo = event.target.value;
                    this.extend.keyup(event);
                }
            },
            lastModifyTime: {
                icon: fa.faCalendar,
                nickname: '最后修改时间',
                value: () => {
                    return this.condition.lastModifyTime;
                },
                focus: (event) => {
                    const dataOF = event.target.value.toString().split(' ~ ');
                    this.condition.lastModifyTimeOUTSET = dataOF[0];
                    this.condition.lastModifyTimeFINISH = dataOF[1];
                    this.listConActivityForecast.func.list.click(event);
                },
                blur: (event) => {
                    this.extend.condition.lastModifyTime.focus(event);
                }
            },
            lastModifier: {
                icon: fa.faUserAlt,
                nickname: '最后修改者',
                value: () => {
                    return this.condition.lastModifier;
                },
                keyup: (event) => {
                    this.condition.lastModifier = event.target.value;
                    this.extend.keyup(event);
                }
            },
        },
    };

    constructor(public listConActivityForecast: ListConActivityForecastComponent) {
        listConActivityForecast.search = this;
    }

    ngOnInit() {
    }

}
